package co.edu.usbcali.ai.ga.samples.x2;

import co.edu.usbcali.ai.ga.ICromosom;
import co.edu.usbcali.ai.ga.Breed;
import co.edu.usbcali.ai.ga.impl.BinaryCromosomType;
import co.edu.usbcali.ai.ga.impl.SimpleCromosom;

public class X2Breed extends Breed {

	public X2Breed(int size) {
		super("X2Breed");
		setCromosomType(new BinaryCromosomType(size));
		setCromosomClass(SimpleCromosom.class);
	}

	@Override
	public float eval(ICromosom cromosom){
		String chain="";
		for(int con=0;con<cromosom.size();con++){
			chain+=cromosom.get(con).toString();
		}
		float res=Integer.parseInt(chain,2);
		return res;		
	}

	@Override
	public String getFenotype(ICromosom cromosom) {
		return String.valueOf(eval(cromosom));
	}
	
	
}
